package com.yyds.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yyds.common.MyJSON;
import com.yyds.mapper.VaccineStatusVoMapper;
import com.yyds.service.VaccineStatusVoService;
import com.yyds.vo.VaccineStatusVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("vaccineStatusVoService")
public class VaccineStatusVoServiceImpl implements VaccineStatusVoService {

    @Autowired
    @Qualifier("vaccineStatusVoMapper")
    private VaccineStatusVoMapper vaccineStatusVoMapper;

    @Override
    public MyJSON<VaccineStatusVo> queryVaccineStatusVoService(Map<String, Object> map) {
        Integer page = Integer.parseInt(map.get("page") + "");
        Integer limit = Integer.parseInt(map.get("limit") + "");
        PageHelper.startPage(page, limit);
        List<VaccineStatusVo> vaccineStatusVos = vaccineStatusVoMapper.queryVaccineStatusVoMapper(map);
        PageInfo<VaccineStatusVo> pageInfo = new PageInfo<>(vaccineStatusVos);
        MyJSON<VaccineStatusVo> myJSON = new MyJSON<>();
        myJSON.setMsg("居民状态信息");
        myJSON.setCode(0);
        myJSON.setData(pageInfo.getList());
        myJSON.setCount(pageInfo.getTotal());
        return myJSON;
    }
}
